<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<title>Processes</title>

	<link
		href="#{facesContext.externalContext.requestContextPath}/resources/css/site/style.css"
		rel="stylesheet" type="text/css" />
	<link
		href="#{facesContext.externalContext.requestContextPath}/resources/css/site/navi.css"
		rel="stylesheet" type="text/css" />

	<script type="text/javascript"
		src="#{facesContext.externalContext.requestContextPath}/resources/css/site/js/jquery-1.8.3.min.js"></script>

	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<script type="text/javascript">
		$(function() {
			$(".box .h_title").not(this).next("ul").hide("normal");
			$(".box .h_title").not(this).next("#process").show("normal");
			$(".box").children(".h_title").click(function() {
				$(this).next("ul").slideToggle();
			});
			//$("#hiddenForm:hiddenButton").css("display", "none);
		});
	</script>

	<h:outputScript library="javascript" name="jscodes.js" />

</h:head>

<h:body>
	<f:view contentType="text/html; charset=UTF-8" encoding="UTF-8">
		<div class="wrap">
			<div id="header">
				<ui:include src="../templates/top.xhtml"></ui:include>
			</div>

			<div id="content">
				<div id="sidebar">
					<ui:include src="../templates/left.xhtml"></ui:include>
				</div>
				<div id="main">
					<div class="clear"></div>
					<h:form id="form">
						<p:growl id="growl" showDetail="true" life="10000" />
						<div class="full_w">

							<p:commandButton action="#{processMB.reloadAllData}"
								id="reloadData" value="Reload All Data"
								update="processTable reloadData growl" ajax="true"></p:commandButton>


							<p:commandButton action="#{processMB.finalizedCurrentProcess}"
								value="Finalize Current Process"
								update="processTable finalizedData growl" id="finalizedData"
								ajax="true" disabled="#{processMB.finalizedButtonVisible}"></p:commandButton>

							<p:commandButton id="exportFile"
								actionListener="#{processMB.exportFile}"
								value="Export Current Process" update="processTable"
								ajax="false" disabled="#{processMB.exportCurrentButtonVisible}"></p:commandButton>

							<p:commandButton action="#{processMB.sendFileToFtp}"
								id="sendFileToFtp" value="Send Current Process to FTP"
								update="processTable" ajax="true"
								disabled="#{processMB.ftpButtonVisible}"></p:commandButton>

						</div>
						<div class="full_w">
							&nbsp;&nbsp;Record :
							<h:selectOneMenu value="#{processMB.selectedRecordId}">
								<f:selectItem itemLabel="Select One" itemValue="-1" />
								<f:selectItems value="#{processMB.recordTypeList}"/>
							</h:selectOneMenu>

							&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Process Id :
							<h:selectOneMenu value="#{processMB.selectedProcessId}">
								<f:selectItem itemLabel="Select One" itemValue="-1" />
								<f:selectItems value="#{processMB.processList}"/>
							</h:selectOneMenu>
							&nbsp; &nbsp; &nbsp;
							<p:commandButton action="#{processMB.reloadSpecificData}"
								id="reloadSpecificData" value="Reload Specific Data"
								update="processTable reloadData growl" ajax="true"></p:commandButton>
						</div>
						<div class="full_w">
							<h1>Processes</h1>
							<p:dataTable id="processTable" value="#{processMB.list}"
								var="record" style="width:700px;" lazy="true"
								emptyMessage="#{bundle.noRecords}" paginator="true" rows="10"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="5,10,15,20,25" rowKey="#{record.id}"
								selection="#{processMB.selectedProcess}" selectionMode="single"
								scrollable="true" scrollWidth="700" scrollHeight="200">
								<p:ajax event="rowSelect"
									listener="#{processMB.showHideButtons}"
									update=":form:finalizedData :form:exportFile" />

								<p:column headerText="Id" footerText="Id" width="50">
									<h:outputText value="#{record.id}" />
								</p:column>

								<p:column headerText="Status" footerText="Status" width="75">
									<h:outputText value="#{record.status}" />
								</p:column>

								<p:column headerText="Week" footerText="Week" width="75">
									<h:outputText value="#{record.week}" />
								</p:column>

								<p:column headerText="Week Ending Date"
									footerText="Week Ending Date" width="100">
									<h:outputText value="#{record.weekEndingDate}" />
								</p:column>

								<p:column headerText="Process Execution Time"
									footerText="Process Execution Time" width="140">
									<h:outputText value="#{record.executionTime}" />
								</p:column>

								<p:column headerText="Process Execution By"
									footerText="Process Execution By" width="120">
									<h:outputText value="#{record.executedBy}" />
								</p:column>

								<p:column headerText="Last File Export Date"
									footerText="Last File Export Date" width="130">
									<h:outputText value="#{record.lastFileExportDate}" />
								</p:column>

								<p:column headerText="Last File Records Count"
									footerText="Last File Records Count" width="130">
									<h:outputText value="#{record.lastFileRecordsCount}" />
								</p:column>

							</p:dataTable>

						</div>
					</h:form>
				</div>
				<div class="clear"></div>
			</div>

			<div id="footer">
				<ui:include src="../templates/footer.xhtml"></ui:include>
			</div>
		</div>

	</f:view>
</h:body>
</html>